/*
	Equivalent to CVDTable in NTOS
*/

#ifndef ABSTRACTVMODEL_H
#define ABSTRACTVMODEL_H

#include <QObject>
#include <QAbstractTableModel>
#include "kdata/VData.h"
#include "kdata/DataSet.h"
#include <QList>
#include <QStringList>

class AbstractVModel : public QAbstractTableModel
{
public:
    enum Role {
          SortRole=Qt::UserRole
       };
    AbstractVModel(int tableIndex, int subTableIndex = 0, QObject *parent = 0);
    ~AbstractVModel();

    int rowCount(const QModelIndex & parent) const;
    int columnCount(const QModelIndex &parent) const;

    QVariant data(const QModelIndex &index, int role) const;
    QVariant headerData(int section, Qt::Orientation orientation, int role) const;

    void append(int ipos);

    void onDataSetUpdate(MSGBUF *msg);

private:
    CVData *db;
    int _tIndex;
    int _subIndex;
    QList<const T_RECDATA*> _data;
    QStringList _fieldList;
    QTextCodec* codec;
    QList<int> _posList;
};

#endif // ABSTRACTVMODEL_H
